package cn.itcast.web.controller.stat;

import cn.itcast.service.stat.StatService;
import cn.itcast.web.controller.BaseController;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(value = "/stat", name = "统计分析")
public class StatController extends BaseController {

    // 实现页面跳转
    @RequestMapping("/toCharts")
    public String toCharts(String chartsType) {
        return "stat/stat-" + chartsType;
    }

    @Reference
    private StatService statService;

    // 厂家销售
    @RequestMapping("/factoryCharts")
    @ResponseBody
    public List<Map> factoryCharts() {
        return statService.findFactoryCharts(getCompanyId());
    }

    // 产品排行榜
    @RequestMapping("/sellCharts")
    @ResponseBody
    public List<Map> sellCharts(){
        return statService.findSellCharts(getCompanyId());
    }

    // 系统访问
    @RequestMapping("/onlineCharts")
    @ResponseBody
    public List<Map> onlineCharts(){
        return statService.findOnlineCharts(getCompanyId());
    }

    //市场价前十名产品
    @RequestMapping("/productCharts")
    @ResponseBody
    public List<Map> productCharts(){
        //返回
        return statService.findProductCharts();
    }

    //统计每个部门的人数
    @RequestMapping("/deptCharts")
    @ResponseBody
    public List<Map> DeptCharts(){
        //返回
        return statService.findDeptCharts();
    }

    // 统计公司内每个人签订的购销合同数
    @RequestMapping("/contractCharts")
    @ResponseBody
    public List<Map> ContractCharts(){
        //返回
        return statService.findContractCharts(getCompanyId());
    }
}
